﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using Common;
using System.ComponentModel;

namespace ServerYuGi.PythonRegister
{
    
    [Serializable]
    [XmlRoot]
    public class CardScript
    {
        [XmlElement]
        public string Check_Point { get; set; }
        [XmlElement]
        public bool IsCheck_Hand { get; set; }
        [XmlElement]        
        public YBool IsCheckFirst { get; set; }
        [XmlElement]        
        public YBool IsAutoDie { get; set; }
        [XmlElement]
        public TypeCheck TypeReCheck { get; set; }
        [XmlElement]
        public string Check_Register_Script_OnHand { get; set; }
        [XmlElement]
        public string Check_Register_Script { get; set; }
        [XmlElement]
        public string Register_Script { get; set; }
        public static CardScript Load(string path)
        {
            CardScript obj = null;
            try
            {
                XmlSerializer xml = new XmlSerializer(typeof(CardScript));
                StreamReader rd = new StreamReader(path);
                obj = xml.Deserialize(rd) as CardScript;
                rd.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return obj;
        }
        public List<ManagementEffect.YCheckPoint> GetListCheckPoint ()
        {
            if (Result!=null)
                return Result;
            List<ManagementEffect.YCheckPoint> result = new List<ManagementEffect.YCheckPoint>();
            if (Check_Point.Equals(""))
                return result;
            string[] tmp = Check_Point.Split(",".ToCharArray());
            foreach (string item in tmp)
            {
                result.Add((ManagementEffect.YCheckPoint)Enum.Parse(typeof(ManagementEffect.YCheckPoint), item));
            }
            Result = result;
            return result;
        }
        
        private List<ManagementEffect.YCheckPoint> Result = null;
    }
    [Serializable]
    public enum YBool
    {
        True,
        False,
    }
   
}
